using System;
using System.Collections.Generic;
using System.Text;

namespace Xeml.Document.EnvironmentalOntology
{
    public abstract class TypeSpecifics
    {
        public decimal NumberVal { get; set; }

        public DateTime DateVal { get; set; }

        public string TextVal { get; set; }

        public bool BooleanVal { get; set; }
        
        public abstract bool Match(object value, VariableDataTypes baseType);

        /// <summary>
        /// taken from here: http://msdn.microsoft.com/en-us/library/w56d4y5z.aspx
        /// </summary>
        public static int CompareTypeSpecificsByName(TypeSpecifics x, TypeSpecifics y)
        {
            if (x == null)
            {
                if (y == null)
                {
                    // If x is null and y is null, they're
                    // equal. 
                    return 0;
                }
                else
                {
                    // If x is null and y is not null, y
                    // is greater. 
                    return -1;
                }
            }
            else
            {
                // If x is not null...
                //
                if (y == null)
                // ...and y is null, x is greater.
                {
                    return 1;
                }
                else
                {
                    // ...and y is not null, compare the 
                    // lengths of the two strings.
                    //
                    int retval = x.TextVal.CompareTo(y.TextVal);

                    if (retval != 0)
                    {
                        // If the strings are not of equal length,
                        // the longer string is greater.
                        //
                        return retval;
                    }
                    else
                    {
                        // If the strings are of equal length,
                        // sort them with ordinary string comparison.
                        //
                        return x.TextVal.CompareTo(y.TextVal);
                    }
                }
            }
        }
    }
}
